import { commonConst } from "../consts/common-const";
import CookieUtil from "./cookie-util";
import SecurityUtil from "./security-util";
import { SessionStorageUtil } from './storage-util';
import Environments from "./env-util";

export default class SysStorageUtil {
    static setSecurityKey(value: any) {
        const timeout = Number.parseFloat(Environments.getEvnProp('VITE_SESSION_TIMEOUT'));
        CookieUtil.set(SecurityUtil.securityKey, value, timeout);
    }

    static getSecurityKey() {
        return CookieUtil.get(SecurityUtil.securityKey);
    }

    static removeSecurityKey() {
        return CookieUtil.remove(SecurityUtil.securityKey);
    }

    static setSessionUser(value: any) {
        const timeout = Number.parseFloat(Environments.getEvnProp('VITE_SESSION_TIMEOUT'));
        CookieUtil.setObject(commonConst.sessionUser, value, timeout);
    }

    static getSessionUser() {
        return CookieUtil.getObject(commonConst.sessionUser);
    }

    static removeSessionUser() {
        return CookieUtil.remove(commonConst.sessionUser);
    }

    static getSessionUserInfo() {
        return SessionStorageUtil.getObject(commonConst.sessionUserInfo);
    }

    static setSessionUserInfo(data: any) {
        SessionStorageUtil.setObject(commonConst.sessionUserInfo, data);
    }

    static removeSessionUserInfo() {
        return SessionStorageUtil.remove(commonConst.sessionUserInfo);
    }

    static setSessionToken(value: any) {
        const timeout = Number.parseFloat(Environments.getEvnProp('VITE_SESSION_TIMEOUT'));
        CookieUtil.setObject(commonConst.sessionToken, value, timeout);
    }

    static getSessionToken() {
        return CookieUtil.getObject(commonConst.sessionToken);
    }

    static removeSessionToken() {
        return CookieUtil.remove(commonConst.sessionToken);
    }
}